package com.douban.business;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import com.douban.business.vo.ItemVO;
import com.douban.business.vo.UserContentItemVO;
import com.douban.constants.DoubanConstant;
import com.douban.constants.DoubanUserActionConstant;

public class DoubanUserContentHolder {
	
	private static Map contentHolder = null;
	
	private static DoubanUserContentHolder thisInstance = null;
	
	private DoubanUserContentHolder(){
		if(contentHolder==null){
			contentHolder=new HashMap();
		}
		
	}
	
	public static DoubanUserContentHolder getInstance(){
		if(thisInstance==null){
			thisInstance = new DoubanUserContentHolder();
		}
		return thisInstance;
	}
	
	public void putContent(String userName, String mediaType, String userAction, Map contentMap){
	
		if( contentHolder.get(userName)==null){
			contentHolder.put(userName, generateMap());
		}else{
			List userContentList = (List)((HashMap)contentHolder.get(userName)).get(userAction);
			userContentList.addAll(contentMap.keySet());			
		}
	}
	
	private HashMap generateMap(){
		HashMap ret = new HashMap();
		ret.put(DoubanUserActionConstant.COLLECT.getValue(), new LinkedList());
		ret.put(DoubanUserActionConstant.DO.getValue(), new LinkedList());
		ret.put(DoubanUserActionConstant.WISH.getValue(), new LinkedList());
		
		return ret;
	}
}
